﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using NUnit.Framework;
using SportsStore.Web.HtmHelpers;
using SportsStore.Web.Models.Helper;

namespace SportsStore.UnitTests.Helpers
{
  [TestFixture]
  public class HelperTests
  {
    #region Setup/Teardown

    [SetUp]
    public void SetUp()
    {
    }

    #endregion

    HtmlHelper helper = null;

    PagingInfoViewModel pagingInfo = new PagingInfoViewModel
    {
      CurrentPage = 2,
      TotalItems = 28,
      ItemsPerPage = 10,
      TotalPages = (int) Math.Ceiling((decimal) 28/10)
    };

    Func<int, string> pageUrlDelegate = i => "Page" + i;

    [Test]
    public void WhenUsingPageLinks_WhenPagingInfoIsValid_IGetAValidPageLink()
    {
      MvcHtmlString result = helper.PageLinks(pagingInfo, pageUrlDelegate);
  
      Assert.AreEqual(result.ToString(), @"<a href=""Page1"">1</a><a class=""selected"" href=""Page2"">2</a><a href=""Page3"">3</a>");
    }
  }
}
